package eos.dom.client;

import eos.dom.DomCardStack;
import eos.dom.DomStart;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class DomCustomArrayAdapter extends ArrayAdapter<DomCardStack> {
	
	//L'ORDRE EST ESSENTIEL. IL DOIT ETRE LE MEME QUE DANS L'ENUM CardId
	public static int[] cards = {
		eos.dom.R.drawable.copper_60x96,
		eos.dom.R.drawable.silver_60x96,
		eos.dom.R.drawable.gold_60x96,
		eos.dom.R.drawable.estate_60x96,
		eos.dom.R.drawable.duchy_60x96,
		eos.dom.R.drawable.province_60x96,
		eos.dom.R.drawable.curse_60x96,
		eos.dom.R.drawable.copper_60x96,
		eos.dom.R.drawable.cellar_60x96,
		eos.dom.R.drawable.chapel_60x96,
		eos.dom.R.drawable.moat_60x96,
		eos.dom.R.drawable.chancellor_60x96,
		eos.dom.R.drawable.village_60x96,
		eos.dom.R.drawable.woodcutter_60x96,
		eos.dom.R.drawable.workshop_60x96,
		eos.dom.R.drawable.bureaucrat_60x96,
		eos.dom.R.drawable.feast_60x96,
		eos.dom.R.drawable.gardens_60x96,
		eos.dom.R.drawable.militia_60x96,
		eos.dom.R.drawable.moneylender_60x96,
		eos.dom.R.drawable.remodel_60x96,
		eos.dom.R.drawable.smithy_60x96,
		eos.dom.R.drawable.spy_60x96,
		eos.dom.R.drawable.thief_60x96,
		eos.dom.R.drawable.throneroom_60x96,
		eos.dom.R.drawable.councilroom_60x96,
		eos.dom.R.drawable.festival_60x96,
		eos.dom.R.drawable.laboratory_60x96,
		eos.dom.R.drawable.library_60x96,
		eos.dom.R.drawable.market_60x96,
		eos.dom.R.drawable.mine_60x96,
		eos.dom.R.drawable.witch_60x96,
		eos.dom.R.drawable.adventurer_60x96
	};
	
	public static int[] bigCards = {
		eos.dom.R.drawable.copper_240x384,
		eos.dom.R.drawable.silver_240x384,
		eos.dom.R.drawable.gold_240x384,
		eos.dom.R.drawable.estate_240x384,
		eos.dom.R.drawable.duchy_240x384,
		eos.dom.R.drawable.province_240x384,
		eos.dom.R.drawable.curse_240x384,
		eos.dom.R.drawable.copper_240x384,
		eos.dom.R.drawable.cellar_240x384,
		eos.dom.R.drawable.chapel_240x384,
		eos.dom.R.drawable.moat_240x384,
		eos.dom.R.drawable.chancellor_240x384,
		eos.dom.R.drawable.village_240x384,
		eos.dom.R.drawable.woodcutter_240x384,
		eos.dom.R.drawable.workshop_240x384,
		eos.dom.R.drawable.bureaucrat_240x384,
		eos.dom.R.drawable.feast_240x384,
		eos.dom.R.drawable.gardens_240x384,
		eos.dom.R.drawable.militia_240x384,
		eos.dom.R.drawable.moneylender_240x384,
		eos.dom.R.drawable.remodel_240x384,
		eos.dom.R.drawable.smithy_240x384,
		eos.dom.R.drawable.spy_240x384,
		eos.dom.R.drawable.thief_240x384,
		eos.dom.R.drawable.throneroom_240x384,
		eos.dom.R.drawable.councilroom_240x384,
		eos.dom.R.drawable.festival_240x384,
		eos.dom.R.drawable.laboratory_240x384,
		eos.dom.R.drawable.library_240x384,
		eos.dom.R.drawable.market_240x384,
		eos.dom.R.drawable.mine_240x384,
		eos.dom.R.drawable.witch_240x384,
		eos.dom.R.drawable.adventurer_240x384
	};

	public DomCustomArrayAdapter(Context context, int textViewResourceId) {
		super(context, textViewResourceId);
		// TODO Auto-generated constructor stub
	}
	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		DomCardStack item = getItem(position);

		LinearLayout v = (LinearLayout)((LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(eos.dom.R.layout.kgriditemlayout, null);
		TextView cardNb = (TextView)v.findViewById(eos.dom.R.id.CardNumber);
		ImageView cardImage = (ImageView)v.findViewById(eos.dom.R.id.CardImage);
		cardNb.setText(""+item.getSize());
		cardImage.setImageResource(cards[item.getId().ordinal()]);
		
		return v;
	}



}
